<?php
namespace app\admin\controller;

use cmf\controller\AdminBaseController;
use think\Db;

class ContentController extends AdminBaseController
{
  public function _initialize()
  {
  }
  
  /**内容列表*/
  public function index ()
  {
  
    $where   = [];
    $request = input('request.');

    
    if (!empty($request['gamename'])) {
      $gamename = $request['gamename'];
      $where['izy_game.gamename'] = array('LIKE', "%$gamename%");
    }
    
    $list = Db::connect('aizuoyou')
      ->name('game')
      ->join('game_order', 'izy_game_order.gid = izy_game.id','left')
      ->join('user', 'izy_game_order.uid = izy_user.uid')
      ->where($where)
      ->field(array('izy_user.uid', 'izy_user.username', 'izy_user.mobile', 'izy_game.gamename', 'izy_game.adname', 'izy_game.thumb', 'izy_game_order.sharelink', 'izy_game.price', 'izy_game.ordernum', 'izy_game.clicknum', 'izy_game.coinnum', 'izy_game_order.gid', 'izy_game.id', 'izy_game_order.shownum'))
      ->order("shownum DESC")
      ->paginate(10);
    
    // 获取分页显示
    $page = $list->render();
    $this->assign('list', $list);
    $this->assign('page', $page);
    // 渲染模板输出
    return $this->fetch();
  }
}